<%--@page import="com.sun.tools.classfile.Annotation.Primitive_element_value"--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" import="DAO.User"%>
<%@page import="java.util.ArrayList"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>CRUD前台</title>
<%--全局样式设置CSS--%>
<style type="text/css">
    body {
    background-image: url("lover.jpg");;
    background-size: 100%;
    background-repeat: no-repeat;
}
#query_frame {
    width:250px;
    height: 240px;
    padding: 10px;
 
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -133px;
    margin-top: -177px;
 
    background-color: rgba(240, 255, 255, 0.5);
 
    border-radius: 10px;
    text-align: right;
}
#update_frame {
    width:250px;
    height: 266px;
    padding: 13px;
 
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: 300px;
    margin-top: -190px;
 
    background-color: rgba(240, 255, 255, 0.5);
 
    border-radius: 10px;
    text-align: right;
}
</style>
</head>
<body>
<%--网页计数器 --%>
<%
	int vCount;
	if(application.getAttribute("visitorcount")==null){
		vCount=1;
	}else{
		vCount=(Integer)application.getAttribute("visitorcount");
		vCount++;
	}
	application.setAttribute("visitorcount", vCount);
%>
<span style="float:right;text-align:center; text-shadow: red;">
<label><b>您是当前网页第 <%=vCount%> 位访问者！<b></label>
<label style="visibility: hidden;"><b>填补空格&实现占位！生活不止眼前的苟且！<b></label>
<label><b style="color: black;">常用功能：</b></label>
<label><a href="Login.jsp">登录</a></label>&nbsp&nbsp&nbsp
<label><a href="Register.jsp">注册</a></label></span>

	
<%--退出登录--%>

	<script type="text/javascript" src="../Static/jquery-1.12.4.min.js"></script>
	<script type="text/javascript">
		$(function() {
			$(".exit").click(
					function() {
						return confirm("确定要退出到游客模式嘛？");
					});
		});
	</script>
	
<%--SuperMan--%>	
 	
	<script type="text/javascript" src="../Static/jquery-1.12.4.min.js"></script>
	<script type="text/javascript">
		$(function() {
			$(".superMan").click(
					function() {
						return confirm("欢迎亲爱的 邵辉 主人！！！---------------您是否进入超级管理模式呢？");
					});
		});
	</script>
	  

<%--判断是游客访问还是用户登录并分别授权 --%>	
<%if(session.getAttribute("loginuser")==null){%>

	<em style="color: black;">当前访问者：</em>
	<b style="color: red;">游客</b><hr>	
	
<%}else{%>		

	<em style="color: black;">当前已登录用户：</em>
	<b style="color: red;">${loginuser}</b>&nbsp&nbsp&nbsp&nbsp
	<a href="Exit.jsp" class="exit" style="color: blue;">退出当前登录</a>&nbsp&nbsp&nbsp&nbsp
	<a href="../View-Admin/view.jsp" class="superMan" style="color: red;">超级管理员？</a>
	<%-- <input type="button" onclick="exit()">--%>

<%--删除时警告框 --%>
	<script type="text/javascript" src="../Static/jquery-1.12.4.min.js"></script>
	<script type="text/javascript">
		$(function() {
			$(".delete").click(
					function() {
						return confirm("确定要删除"
								+ $(this).parent().parent().find("td:eq(1)")
										.text() + "嘛？");
					});
		});
	</script>
	
<%--模糊查询页面布局 --%>
	<div id="query_frame">	
	<form action="../query.do">
				<i>Query：查询表</i><hr>
				Id：<label><input type="text"placeholder="Id" name="Id"/></label><br> 
				Name：<label><input type="text"placeholder="Name" name="Name" /></label><br>
				Password：<label><input type="text" placeholder="Password" name="Password" /></label> 
				<div style="text-align: center;">Sex：&nbsp&nbsp&nbsp&nbsp<input style="a" type="radio" value="男" name="Sex">男&nbsp&nbsp<input type="radio" value="女" name="Sex">女</div>
				Question：<label><input type="text" placeholder="Question"name="Question" /></label> <br> 
				Answer：<label><input type="text" placeholder="Answer" name="Answer"/></label> <br> 
				Email：<label><input type="text" placeholder="Email" name="Email"/></label> <br><hr>			
		<input type="submit" value="query" style="position: absolute;"> 
		  	  <div >           
           <span style="color: white;font-size: small;">Have a member?</span>            
           <a href="Login.jsp" style="color: red;"> Go and login in </a>
        </div>
	</form>
	</div>
	
<%--Update页面布局 --%>
	<%
	User upuser=(User)session.getAttribute("upuser");
	if(upuser!=null){
	%>
	<div id="update_frame">	
	<form action="../update.do">
		<b>Update：更新表</b><hr>
		 <input type="text" style="visibility: hidden;" name="Id" value="${upuser.getId()}"><br>
		 Name：<input type="text" name="Name" value="${upuser.getName()}"><br>
		 Password：<input type="text" name="Password" value="${upuser.getPassword()}"><br> 
		<%
		if("男".equals(upuser.getSex())){
			%>
			<div style="text-align: center;">Sex：&nbsp&nbsp&nbsp&nbsp<input style="a" type="radio" checked="checked" value="男" name="Sex">男&nbsp&nbsp<input type="radio"value="女" name="Sex" >女</div>
		<% }else if("女".equals(upuser.getSex())){%>
			<div style="text-align: center;">Sex：&nbsp&nbsp&nbsp&nbsp<input style="a" type="radio" value="男" name="Sex">男&nbsp&nbsp<input type="radio" checked="checked"value="女" name="Sex" >女</div>
		<%}
		else{%>
			<div style="text-align: center;">Sex：&nbsp&nbsp&nbsp&nbsp<input style="a" type="radio" value="男" name="Sex">男&nbsp&nbsp<input type="radio"value="女" name="Sex" >女</div>
		<%}
		%>		 
		 Question：<input type="text"name="Question" value="${upuser.getQuestion()}"><br> 
		 Answer：<input type="text"name="Answer"value="${upuser.getAnswer()}"><br> 
		 Email：<input type="text" name="Email"value="${upuser.getEmail()}"><br><br><hr>
		<input type="submit" value="update" >
		<input type="checkbox" checked="checked">
		<input type="reset" value="clear up" > <br>
          <div >           
           <span style="color: white;font-size: small;">Not a member yet?</span>            
           <a href="Register.jsp" style="color: blue;"> Go And Sign Up </a>
        </div>
	</form>
	</div><%}%>
	
<%--模糊查询结果表 --%>
	<%
		ArrayList<User> userlists = (ArrayList<User>) session.getAttribute("dimuser");
	if (userlists != null) {
	%>
	<hr style="color: red;">
	<table border="1" style="text-align: center;">
		<tr>
			<th>Id</td>
			<th>Name</td>
			
			<th>Sex</td>
			<th colspan="3" style="text-align: center;">操作</th>
		</tr>
		<%
			for (User user : userlists) {
		%>
		<tr>
			<td><%=user.getId()%></td>
			<td><%=user.getName()%></td>
			
			<td><%=user.getSex()%></td>
			<td><a href="../query.do?id=<%=user.getId()%>">Query</a></td>
			<td><a href="../delete.do?id=<%=user.getId()%>" class="delete">Delete</a></td>
			<td><a href="../edit.do?id=<%=user.getId()%>">Update</a></td>
		</tr>
		<%
			}
		}
		%>
	</table>
	<hr>
	
<%-- 个人查询结果表--%>
	<%
	User user=(User)session.getAttribute("privateuser");
	if(user!=null){
	%>
	<table border="1" style="text-align: center;" align="center">	
		<tr>
			<th>Id</td>
			<th>Name</td>
			<th>Password</td>
			<th>Sex</td>
			<th>Question</td>
			<th>Answer</td>
			<th>Email</td>
		</tr>
		<tr>
			<td><%=user.getId()%></td>
			<td><%=user.getName()%></td>
			<td><%=user.getPassword()%></td>
			<td><%=user.getSex()%></td>
			<td><%=user.getQuestion()%></td>
			<td><%=user.getAnswer()%></td>
			<td><%=user.getEmail()%></td>
		</tr>
	</table>
	
	
	<%--利用Cookies	读取用户浏览记录 	--%>	
<%--
Cookie[] cookies=request.getCookies();
if(cookies!=null){
	for(Cookie cookie :cookies){
		out.println(cookie.getValue());
	}
}
--%>		
	<%}%>
	
	
<%}%>
</body>
</html>